#! /bin/sh
echo "镜像网址---registry.cn-shanghai.aliyuncs.com/jokerak/ai-flask"
containerId=`docker ps -a | grep -w registry.cn-shanghai.aliyuncs.com/jokerak/ai-flask | awk '{print $1}'`
if [ "$containerId" != "" ] ; then
#停掉容器
  docker stop $containerId
#删除容器
  docker rm $containerId
  echo "成功删除容器"
fi
#查询镜像是否存在，存在则删除
imageId=`docker images | grep -w registry.cn-shanghai.aliyuncs.com/jokerak/ai-flask | awk '{print $3}'`
if [ "$imageId" != "" ] ; then
#删除镜像
 docker rmi -f $imageId
 echo "成功删除镜像"
fi
# 登录Harbor私服
docker login --username=fakerlove7 -p 1654697013wan registry.cn-shanghai.aliyuncs.com
# 下载镜像
docker pull registry.cn-shanghai.aliyuncs.com/jokerak/ai-flask
# 启动容器
docker run -di -p 5000:5000 --name ai_flask registry.cn-shanghai.aliyuncs.com/jokerak/ai-flask
echo "容器启动成功"
